package models

import (
	"time"

	"github.com/astaxie/beego/orm"
)

//User 用户表
type User struct {
	Id         int64     `json:"id"`
	UserName   string    `orm:"unique;size(32)" form:"Username"  valid:"Required;MaxSize(20);MinSize(6)" json:"username"`
	Password   string    `orm:"size(128)" form:"Password" valid:"Required;MaxSize(20);MinSize(6)" json:"password"`
	FirstName  string    `orm:"size(32)" form:"FirstName"  valid:"Required;MaxSize(20);MinSize(1)" json:"firstname"`
	LastName   string    `orm:"size(64)" form:"LastName"  valid:"Required;MaxSize(20);MinSize(6)" json:"lastname"`
	IsActive   bool      `orm:"type(bool)" json:"is_active"`
	Createtime time.Time `orm:"type(datetime);auto_now_add" json:"create_time"`
}

//Session 存储用户 session
type Session struct {
	Id     int64
	User   *User     `orm:"rel(fk)"`
	Value  string    `orm:"size(128)" form:"Value" valid:"Required;MaxSize(128);MinSize(6)"`
	Expire time.Time `orm:"type(datetime);auto_now_add" `
}

func init() {
	orm.RegisterModel(new(User))
	orm.RegisterModel(new(Session))
}
